package com.xzr.yespaper.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 检测登陆状态的拦截器，失败则重定向到主页
 */
public class LoginJudge implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        HttpSession session = request.getSession();
//        Object user = session.getAttribute("user");
//        if (user!=null){
//            return true;
//        }
//        request.setAttribute("message","Please Login first!");
//        request.getRequestDispatcher("/").forward(request, response);
//        return false;
        return true;
    }
}